#购物系统业务需求V1.0
money = 5000
goods = ['手机', '电脑', '耳机', '键盘', '生活用品', '数码相机', '衣物']
prices = [1000, 4000, 200, 230, 100, 10000, 523]
cars = []
run = True
while (run):
    good = input("请输入你要买的商品：")
    temple = 1
    for index, good1 in enumerate(goods):
        if good1 == good:
            temple = 0
            if money >= prices[index]:
                cars.append(good1)
                money -= prices[index]
                print("恭喜，购买成功！您的卡余额还剩", money)
            else:
                print("穷鬼，钱不够！请到其他超市购买！")
    if temple == 1:
        print("没有这个商品，别瞎弄！")
    start = input("输入Q退出购物，随意输入继续购物") != 'Q'
    run = start
for car in cars:
    for index, good2 in enumerate(goods):
        if car == good2:
            print("商品:", car, "价格:", prices[index])
#购物系统业务需求V2.0
import datetime
import random
money = 5000
goods = ['手机', '电脑', '耳机', '键盘', '生活用品', '数码相机', '衣物']
prices = [1000, 4000, 200, 230, 100, 10000, 523]
discounts = ['手机8折优惠劵', '手机6折优惠劵', '电脑8折优惠劵', '电脑6折优惠劵', '手机1折优惠劵']
disnums = [0.8, 0.6, 0.8, 0.6, 0.1]
udiscounts = []
udisnums = []
num = random.randint(0, 4)
udiscounts.append(discounts[num])
udisnums.append(disnums[num])
cars = []
run = True
while (run):
    good = input("请输入你要买的商品：")
    temple = 1
    for index, good1 in enumerate(goods):
        if good1 == good:
            temple = 0
            price = prices[index]
            if udiscounts:
                if good in udiscounts[0]:
                    price *= udisnums[0]
                    udiscounts.pop()
            if money >= price:
                cars.append(good1)
                money -= price
                print("恭喜，购买成功！您的卡余额还剩", money)
            else:
                print("穷鬼，钱不够！请到其他超市购买！")
    back = input("是否需要退货，需要退货输入yes反之随意输入") == "yes"
    if back:
        backrun = True
        while(backrun):
            backgood = input("请输入要退的商品")
            backprice = 0
            if cars:
                if backgood in cars:
                    for index, good2 in enumerate(goods):
                        if backgood == good2:
                            backprice = prices[index]
                            break
                    cars.remove(backgood)
                    money += backprice
                    print("退货成功，卡余额为", money)
                    print("购物车的商品为", cars)
                else:
                    print("购物车中没有该商品")
            else:
                print("购物车为空无法进行退货")
                break
            backrun = input("是否继续退货,继续输入yes反之任意输入") == "yes"
    if temple == 1:
        print("没有这个商品，别瞎弄！")
    start = input("输入Q退出购物，随意输入继续购物") != 'Q'
    run = start
total = 0
print("购物时间:", datetime.datetime.now())
for car in cars:
    for index, good2 in enumerate(goods):
        if car == good2:
            total += prices[index]
            print("商品:", car, "价格:", prices[index])
print("总商品价值:", total)
print("卡的余额:", money)